<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Swagger UI</title>
    <link rel="stylesheet" type="text/css" href="{{ base_path }}/common_static/lib/swagger/swagger-ui.css" />
    <link rel="stylesheet" type="text/css" href="{{ base_path }}/common_static/lib/swagger/index.css" />
    <link rel="icon" type="image/png" href="{{ base_path }}/common_static/lib/swagger/favicon-32x32.png" sizes="32x32" />
    <link rel="icon" type="image/png" href="{{ base_path }}/common_static/lib/swagger/favicon-16x16.png" sizes="16x16" />
  </head>

  <body>
    <div id="swagger-ui"></div>
    <script src="{{ base_path }}/common_static/lib/swagger/swagger-ui-bundle.js" charset="UTF-8"> </script>
    <script src="{{ base_path }}/common_static/lib/swagger/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
    <script>
      window.onload = function() {
        window.ui = SwaggerUIBundle({
          url: '{{ base_path }}/openapi.yaml',
          dom_id: '#swagger-ui',
          deepLinking: true,
          presets: [
            SwaggerUIBundle.presets.apis,
            SwaggerUIStandalonePreset
          ],
          plugins: [
            SwaggerUIBundle.plugins.DownloadUrl
          ],
          layout: "StandaloneLayout",
          requestInterceptor: function(request) {
            // Get CSRF token from template variable
            const csrfToken = "{{ csrf_token }}";

            if (csrfToken) {
              // Add CSRF token to request headers
              if (!request.headers) {
                request.headers = {};
              }
              request.headers['X-CSRF-Token'] = csrfToken;
            }

            return request;
          }
        });
      };
    </script>
  </body>
</html>
